const { sequelize } = require("../../core/db");
const { Sequelize, Model } = require("sequelize");


class Activity extends Model {}

Activity.init(
  {
    activity_id: {
      type: Sequelize.INTEGER,
      primaryKey: true,
      autoIncrement: true,
    },
    title: {
      //活动标题
      type: Sequelize.STRING,
      allowNull: false,
    },
    image: Sequelize.STRING, //活动图片
    sort: {
      type: Sequelize.INTEGER,
      comment: "排序",
      defaultValue: 1,
      allowNull: false,
    },
    price: {
      type: Sequelize.INTEGER,
      comment: "活动价格",
      defaultValue: 1,
      allowNull: false,
    },
    enrollment: {
      //报名人数
      type: Sequelize.INTEGER,
      allowNull: false,
      defaultValue: 0,
    },
    deadline: Sequelize.DATE, //活动截止时间
    start: Sequelize.DATE, //活动开始时间

    activity_time: Sequelize.DATE, //活动时间
    condition: {
      // 活动条件
      type: Sequelize.INTEGER,
      defaultValue: 0,
    },

    is_destroy: {
      // 是否上架下架
      type: Sequelize.BOOLEAN,
      defaultValue: false, //活动默认下架
    },
    admin_id: Sequelize.INTEGER, // 创建活动的管理员
    address: {
      //活动地址
      type: Sequelize.STRING,
      comment: "活动地点",
      allowNull: false,
    },
    //经纬度
    longitude: {
      type: Sequelize.STRING,
      allowNull: false,
      comment: "经度",
    },

    content: {
      //活动详情
      type: Sequelize.TEXT,
      allowNull: false,
    },
  },
  {
    sequelize,
    tableName: "activity",
  }
);

module.exports = {
  Activity,
};
